package kr.hkit.powerjava.chapter22.work2;

import java.util.ArrayList;
import java.util.Comparator;

import kr.hkit.powerjava.chapter22.work2.dao.DepartmentManagerImpl;
import kr.hkit.powerjava.chapter22.work2.vo.Department;

public class Testmain2 {
	public static void main(String[] args) {
		ArrayList<Department> deList = new ArrayList<>();
		DepartmentManagerImpl dm = new DepartmentManagerImpl(deList);
		
		//추가
		Department dep1 = new Department(4099, "정보공학", 4);
		dm.addItem(dep1);
		dm.addItem(new Department(4199, "전산공학", 3));
		dm.addItem(new Department(4288, "통신", 5));
		dm.addItem(new Department(4376, "임베디드", 7));
		
		
		//삭제
//		dm.delItem(dep1);
		
		//검색
		Department searchDept = new Department(4199, "전산공학");
		String result = dm.searchItem(searchDept)?"존재":"음슴";
		System.out.println(searchDept.getDeptNo() + ":" + searchDept.getDeptName() + " = " + result);
		//수정
		//학과 위치 고치기
		Department updateDep = new Department(4099, "정보공학", 9);
		dm.updateItem(updateDep);
		
		//출력
		dm.prnItems();
		System.out.println("학과번호순 정렬");
		dm.pinItems(new Comparator<Department>() {
			
			@Override
			public int compare(Department o1, Department o2) {
				
				return o1.getDeptNo() - o2.getDeptNo();
			}
		});
		
		System.out.println("위치순 정렬");
		dm.pinItems(new Comparator<Department>() {
			
			@Override
			public int compare(Department o1, Department o2) {
				
				return o2.getFloor() - o1.getFloor();
			}
		});
	}
	
}
